/**
 * Created by 李爱珍 on 2016/11/21.
 */
'use strict';
//1.开启服务器
//获取环境变量中监听的端口号
let port=process.env.PORT||8887;
const  express=require('express');
const  orm=require('orm');
let app=express();

//2.初始化数据
 app.use(orm.express('mysql://root:123456@127.0.0.1:3306/test',{
   define:function(db,models,next){
       models.userinfo=db.define('userinfo',{
           uid:{type:'serial',key:true},
           uname:String,
           upwd:String,
           ustatus:Number
       });
       models.videoinfo=db.define('videoinfo',{
           vid:{type:'serial',key:true},
           vtitle:String,
           vsortnum:Number,
           vvideoID:String ,
           vsummary:String,
           vremark:String,
           vimg:String
       });
       next();
   }
 }));

//3.设置路由规则
let  accountRoute=require('./routers/accountRouter.js');
app.use('/account',accountRoute);
//设置admin
//4.静态加载数据
 let path=__dirname + '/statics';
//let path= './statics';
console.log(path)
app.use(express.static(path));
//5.开启监听
app.listen(port,'127.0.0.1',()=>{
    console.log('服务器开启成功');
})


